{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "initial_id",
   "metadata": {
    "collapsed": true,
    "ExecuteTime": {
     "end_time": "2023-12-04T02:05:36.398743300Z",
     "start_time": "2023-12-04T02:05:36.357138600Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": "     brand_name outter_name  dcar_score         car_name  year  \\\n0           比亚迪          海鸥        3.30              活力版  2023   \n1           比亚迪          海鸥        3.30              自由版  2023   \n2           比亚迪          海鸥        3.30              飞翔版  2023   \n3           特斯拉     Model Y        4.04            后轮驱动版  2023   \n4           特斯拉     Model Y        4.04         长续航全轮驱动版  2023   \n...         ...         ...         ...              ...   ...   \n2244      新吉奥汽车        吉奥帅豹        0.00  栏板41.6kWh奥远动力电机  2024   \n2245      新吉奥汽车        吉奥帅豹        0.00    仓栅41.6kWh菱电电机  2024   \n2246      新吉奥汽车        吉奥帅豹        0.00    箱货41.6kWh菱电电机  2024   \n2247      新吉奥汽车        吉奥帅豹        0.00    栏板41.6kWh菱电电机  2024   \n2248      SRM鑫源          豪运        0.00            创业型厢货  2023   \n\n      official_price  dealer_price  \n0               7.38          7.38  \n1               7.88          7.88  \n2               8.98          8.98  \n3              26.64         26.64  \n4              30.64         30.64  \n...              ...           ...  \n2244           15.08         15.08  \n2245           15.38         15.38  \n2246           15.48         15.48  \n2247           15.08         15.08  \n2248           20.18         20.18  \n\n[2249 rows x 7 columns]",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>brand_name</th>\n      <th>outter_name</th>\n      <th>dcar_score</th>\n      <th>car_name</th>\n      <th>year</th>\n      <th>official_price</th>\n      <th>dealer_price</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>比亚迪</td>\n      <td>海鸥</td>\n      <td>3.30</td>\n      <td>活力版</td>\n      <td>2023</td>\n      <td>7.38</td>\n      <td>7.38</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>比亚迪</td>\n      <td>海鸥</td>\n      <td>3.30</td>\n      <td>自由版</td>\n      <td>2023</td>\n      <td>7.88</td>\n      <td>7.88</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>比亚迪</td>\n      <td>海鸥</td>\n      <td>3.30</td>\n      <td>飞翔版</td>\n      <td>2023</td>\n      <td>8.98</td>\n      <td>8.98</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>特斯拉</td>\n      <td>Model Y</td>\n      <td>4.04</td>\n      <td>后轮驱动版</td>\n      <td>2023</td>\n      <td>26.64</td>\n      <td>26.64</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>特斯拉</td>\n      <td>Model Y</td>\n      <td>4.04</td>\n      <td>长续航全轮驱动版</td>\n      <td>2023</td>\n      <td>30.64</td>\n      <td>30.64</td>\n    </tr>\n    <tr>\n      <th>...</th>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n    </tr>\n    <tr>\n      <th>2244</th>\n      <td>新吉奥汽车</td>\n      <td>吉奥帅豹</td>\n      <td>0.00</td>\n      <td>栏板41.6kWh奥远动力电机</td>\n      <td>2024</td>\n      <td>15.08</td>\n      <td>15.08</td>\n    </tr>\n    <tr>\n      <th>2245</th>\n      <td>新吉奥汽车</td>\n      <td>吉奥帅豹</td>\n      <td>0.00</td>\n      <td>仓栅41.6kWh菱电电机</td>\n      <td>2024</td>\n      <td>15.38</td>\n      <td>15.38</td>\n    </tr>\n    <tr>\n      <th>2246</th>\n      <td>新吉奥汽车</td>\n      <td>吉奥帅豹</td>\n      <td>0.00</td>\n      <td>箱货41.6kWh菱电电机</td>\n      <td>2024</td>\n      <td>15.48</td>\n      <td>15.48</td>\n    </tr>\n    <tr>\n      <th>2247</th>\n      <td>新吉奥汽车</td>\n      <td>吉奥帅豹</td>\n      <td>0.00</td>\n      <td>栏板41.6kWh菱电电机</td>\n      <td>2024</td>\n      <td>15.08</td>\n      <td>15.08</td>\n    </tr>\n    <tr>\n      <th>2248</th>\n      <td>SRM鑫源</td>\n      <td>豪运</td>\n      <td>0.00</td>\n      <td>创业型厢货</td>\n      <td>2023</td>\n      <td>20.18</td>\n      <td>20.18</td>\n    </tr>\n  </tbody>\n</table>\n<p>2249 rows × 7 columns</p>\n</div>"
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import pandas as pd\n",
    "\n",
    "df = pd.read_csv(\"../static/data/car_info_pre.csv\")\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "C:\\Users\\Administrator\\AppData\\Local\\Temp\\ipykernel_132\\805969971.py:2: UserWarning: Boolean Series key will be reindexed to match DataFrame index.\n",
      "  df_line = df_outter[df['year'] <= 2023].groupby('year').count()['outter_name'].reset_index()\n"
     ]
    },
    {
     "data": {
      "text/plain": "{'name': [2015, 2018, 2019, 2020, 2021, 2022, 2023],\n 'value': [2, 6, 10, 13, 37, 117, 208]}"
     },
     "execution_count": 36,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_outter = df.drop_duplicates(subset=['outter_name'], keep='first')\n",
    "df_line = df_outter[df['year'] <= 2023].groupby('year').count()['outter_name'].reset_index()\n",
    "name = df_line.year.values.tolist()\n",
    "value = df_line.outter_name.values.tolist()\n",
    "{\n",
    "    'name': name,\n",
    "    'value': value\n",
    "}"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2023-12-04T02:26:31.811446600Z",
     "start_time": "2023-12-04T02:26:31.798402200Z"
    }
   },
   "id": "5657bfd8715ed5f1"
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "outputs": [
    {
     "data": {
      "text/plain": "{'name': ['保时捷-Taycan',\n  '奔驰-奔驰EQS',\n  '蔚来-蔚来ET7',\n  '高合-高合HiPhi X',\n  '宝马-宝马iX',\n  '路特斯-路特斯Eletre',\n  '智己汽车-智己L7',\n  '极氪-ZEEKR 001',\n  '特斯拉-Model S',\n  '岚图-岚图梦想家 EV'],\n 'value': [4.31, 4.3, 4.16, 4.16, 4.15, 4.13, 4.12, 4.12, 4.12, 4.11]}"
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_outter = df.drop_duplicates(subset=['outter_name'], keep='first')\n",
    "df_bar = df_outter.sort_values(by='dcar_score', ascending=False).head(10)\n",
    "name = ['-'.join(i) for i in df_bar[['brand_name', 'outter_name']].values]\n",
    "value = df_bar.dcar_score.values.tolist()\n",
    "{\n",
    "    'name': name,\n",
    "    'value': value\n",
    "}"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2023-12-04T02:05:36.409373300Z",
     "start_time": "2023-12-04T02:05:36.396744400Z"
    }
   },
   "id": "e294ea6c4ac1db88"
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "outputs": [
    {
     "data": {
      "text/plain": "{'name': '全部',\n 'children': [{'name': 'AITO', 'children': [{'name': '问界M5'}]},\n  {'name': 'ARCFOX极狐',\n   'children': [{'name': '极狐 阿尔法S'}, {'name': '极狐考拉'}, {'name': '极狐 阿尔法T'}]},\n  {'name': 'DS', 'children': [{'name': 'DS 3 EV'}]},\n  {'name': 'LEVC', 'children': [{'name': 'LEVC TX'}]},\n  {'name': 'Polestar极星',\n   'children': [{'name': 'Polestar 4'},\n    {'name': 'Polestar 2'},\n    {'name': 'Polestar 3'}]},\n  {'name': 'SRM鑫源',\n   'children': [{'name': '海狮 EV'},\n    {'name': '小海狮 EV'},\n    {'name': '好运1号'},\n    {'name': '鑫源T1L EV'},\n    {'name': '好运'},\n    {'name': 'T2S EV'},\n    {'name': 'T5L EV'},\n    {'name': '鑫源T3L EV'},\n    {'name': '启运'},\n    {'name': '豪运'}]},\n  {'name': 'smart',\n   'children': [{'name': 'smart精灵#1'}, {'name': 'smart精灵#3'}]},\n  {'name': '万象汽车',\n   'children': [{'name': '万象T01'},\n    {'name': '万象T02'},\n    {'name': '万象DST神州5号'},\n    {'name': '万象K01'}]},\n  {'name': '三菱', 'children': [{'name': '阿图柯AIRTREK'}]},\n  {'name': '上汽大通MAXUS',\n   'children': [{'name': '上汽大通MAXUS 大家7'},\n    {'name': '上汽大通MAXUS 大家9'},\n    {'name': '上汽大通MAXUS 大家5'},\n    {'name': '上汽大通MAXUS EV30'},\n    {'name': '上汽大通MAXUS 大家6'},\n    {'name': '上汽大通MAXUS EV80'},\n    {'name': '上汽大通MAXUS EV90'},\n    {'name': '上汽大通MAXUS 大拿V1'},\n    {'name': '上汽大通MAXU 新途EV70'},\n    {'name': '上汽大通MAXUS T90 EV'}]},\n  {'name': '东南', 'children': [{'name': 'SEM DELICA'}]},\n  {'name': '东风',\n   'children': [{'name': '御风EM26'}, {'name': '锐骐6 EV'}, {'name': '御风EV'}]},\n  {'name': '东风·瑞泰特',\n   'children': [{'name': '东风·瑞泰特EM10'}, {'name': '东风·瑞泰特EM30'}]},\n  {'name': '东风富康',\n   'children': [{'name': 'e爱丽舍'}, {'name': '富康ES600'}, {'name': '富康ES500'}]},\n  {'name': '东风小康', 'children': [{'name': '东风小康EC36'}, {'name': '东风小康EC36Ⅱ'}]},\n  {'name': '东风纳米', 'children': [{'name': '纳米BOX'}, {'name': '东风纳米EX1'}]},\n  {'name': '东风风光', 'children': [{'name': '风光MINIEV'}, {'name': '风光E380'}]},\n  {'name': '东风风神', 'children': [{'name': '东风风神E70'}, {'name': 'SKY EV01'}]},\n  {'name': '东风风行',\n   'children': [{'name': '风行雷霆'},\n    {'name': '菱智M5 EV'},\n    {'name': '风行S50 EV'},\n    {'name': '风行S60 EV'}]},\n  {'name': '丰田',\n   'children': [{'name': '丰田bZ3'},\n    {'name': '一汽丰田bZ4X'},\n    {'name': '广汽丰田bZ4X'},\n    {'name': '广汽丰田铂智4X'}]},\n  {'name': '九龙',\n   'children': [{'name': '九龙E6'}, {'name': '九龙EM3'}, {'name': '九龙EW5'}]},\n  {'name': '云度', 'children': [{'name': '云兔'}, {'name': '云度π1'}]},\n  {'name': '五十铃', 'children': [{'name': '瑞迈EV'}]},\n  {'name': '五菱汽车',\n   'children': [{'name': '五菱缤果'},\n    {'name': '五菱宏光MINIEV'},\n    {'name': '五菱Air ev晴空'},\n    {'name': '五菱Nano EV'},\n    {'name': '五菱征程EV'},\n    {'name': '五菱荣光EV'},\n    {'name': '五菱E10'},\n    {'name': '五菱EV50'},\n    {'name': '五菱电卡'},\n    {'name': '五菱荣光新卡EV'},\n    {'name': '五菱EV80'},\n    {'name': '五菱荣光小卡EV'}]},\n  {'name': '依维柯', 'children': [{'name': '依维柯聚星 EV'}, {'name': '依维柯欧胜EV'}]},\n  {'name': '保时捷', 'children': [{'name': 'Taycan'}]},\n  {'name': '凌宝汽车',\n   'children': [{'name': '凌宝BOX'}, {'name': '凌宝Uni'}, {'name': '凌宝COCO'}]},\n  {'name': '凯翼', 'children': [{'name': '凯翼拾月'}, {'name': '炫界Pro EV'}]},\n  {'name': '凯迪拉克', 'children': [{'name': 'IQ锐歌'}]},\n  {'name': '凯马汽车', 'children': [{'name': '骏航'}]},\n  {'name': '创维汽车', 'children': [{'name': '创维EV6'}]},\n  {'name': '别克',\n   'children': [{'name': '别克E5'}, {'name': '微蓝6'}, {'name': '别克E4'}]},\n  {'name': '劳斯莱斯', 'children': [{'name': '闪灵'}]},\n  {'name': '北京汽车',\n   'children': [{'name': '北京EU5'},\n    {'name': '北京EU5 PLUS'},\n    {'name': '北京EU7'},\n    {'name': '北京EX3'},\n    {'name': '北京EX5'}]},\n  {'name': '北汽制造',\n   'children': [{'name': '元宝'},\n    {'name': '王牌M7 EV'},\n    {'name': '家宝'},\n    {'name': '北汽小河马'},\n    {'name': '鲸卡T7 EV'}]},\n  {'name': '北汽昌河', 'children': [{'name': '北汽EV5'}]},\n  {'name': '北汽瑞翔', 'children': [{'name': '北汽瑞翔V2 EV'}]},\n  {'name': '北汽雷驰',\n   'children': [{'name': '小卡'}, {'name': 'MINI卡'}, {'name': 'MINI皮卡'}]},\n  {'name': '华凯', 'children': [{'name': '华凯新能源VE06'}, {'name': '华凯新能源'}]},\n  {'name': '华夏领舰', 'children': [{'name': '华夏领舰HX-1'}]},\n  {'name': '华晨新日', 'children': [{'name': '华晨新日i03'}, {'name': '华晨新日i03A'}]},\n  {'name': '华梓汽车', 'children': [{'name': '欧麦加'}]},\n  {'name': '合创汽车',\n   'children': [{'name': '合创V09'},\n    {'name': '合创A06'},\n    {'name': '合创Z03'},\n    {'name': '合创007'}]},\n  {'name': '吉利几何',\n   'children': [{'name': '吉利几何E萤火虫'},\n    {'name': '吉利几何G6'},\n    {'name': '吉利几何A'},\n    {'name': '吉利几何C'},\n    {'name': '吉利几何M6'},\n    {'name': '帝豪EV'}]},\n  {'name': '吉利汽车', 'children': [{'name': '熊猫'}]},\n  {'name': '名爵', 'children': [{'name': 'MG Cyberster'}, {'name': 'MG4 EV'}]},\n  {'name': '启辰',\n   'children': [{'name': '启辰VX6'},\n    {'name': '启辰D60 EV'},\n    {'name': '启辰T60 EV'}]},\n  {'name': '哪吒汽车',\n   'children': [{'name': '哪吒S'},\n    {'name': '哪吒GT'},\n    {'name': '哪吒U'},\n    {'name': '哪吒V'},\n    {'name': '哪吒X'},\n    {'name': '哪吒AYA'}]},\n  {'name': '国吉商用车', 'children': [{'name': '大象G30'}, {'name': '大象G40'}]},\n  {'name': '国新新能源', 'children': [{'name': '翼刻ET300'}]},\n  {'name': '国金汽车', 'children': [{'name': '骏行'}]},\n  {'name': '埃安',\n   'children': [{'name': 'AION Y'},\n    {'name': 'AION S'},\n    {'name': 'AION V'},\n    {'name': 'AION LX'}]},\n  {'name': '大众',\n   'children': [{'name': '大众ID.3'},\n    {'name': 'ID.4 CROZZ'},\n    {'name': 'ID.4 X'},\n    {'name': 'ID.6 CROZZ'},\n    {'name': 'ID.6 X'}]},\n  {'name': '大力牛魔王',\n   'children': [{'name': '大力牛魔王D01'},\n    {'name': '大力牛魔王D02'},\n    {'name': '大力牛魔王D05'}]},\n  {'name': '大运', 'children': [{'name': '悦虎'}, {'name': '远志M1'}]},\n  {'name': '天际汽车', 'children': [{'name': '天际ME7'}]},\n  {'name': '奇瑞新能源',\n   'children': [{'name': 'QQ冰淇淋'},\n    {'name': '小蚂蚁'},\n    {'name': '奇瑞舒享家'},\n    {'name': '无界Pro'},\n    {'name': '艾瑞泽e'}]},\n  {'name': '奔腾', 'children': [{'name': '奔腾NAT'}, {'name': '奔腾E01'}]},\n  {'name': '奔驰',\n   'children': [{'name': '奔驰EQE'},\n    {'name': '奔驰EQE SUV'},\n    {'name': '奔驰EQC'},\n    {'name': '奔驰EQS'},\n    {'name': '奔驰EQA'},\n    {'name': '奔驰EQB'},\n    {'name': '奔驰EQS SUV'},\n    {'name': '奔驰EQS AMG'},\n    {'name': '奔驰EQE AMG'}]},\n  {'name': '奥迪',\n   'children': [{'name': '奥迪Q5 e-tron'},\n    {'name': '奥迪Q4 e-tron'},\n    {'name': '奥迪e-tron'},\n    {'name': '奥迪RS e-tron GT'},\n    {'name': '奥迪e-tron GT'},\n    {'name': '奥迪Q2L e-tron'},\n    {'name': '奥迪e-tron Sportback(进口)'}]},\n  {'name': '宇通客车', 'children': [{'name': '宇通T7E'}]},\n  {'name': '安凯客车', 'children': [{'name': '安凯快乐运'}, {'name': '安凯Q5'}]},\n  {'name': '宏远汽车', 'children': [{'name': '宏远EM60'}]},\n  {'name': '宝马',\n   'children': [{'name': '宝马i3'},\n    {'name': '宝马iX3'},\n    {'name': '宝马i4'},\n    {'name': '宝马iX'},\n    {'name': '宝马iX1'},\n    {'name': '宝马i7'}]},\n  {'name': '宝骏',\n   'children': [{'name': '悦也'}, {'name': '云朵'}, {'name': '宝骏KiWi EV'}]},\n  {'name': '容大智造', 'children': [{'name': '迈图'}, {'name': '迈乔'}]},\n  {'name': '小虎', 'children': [{'name': '小虎FEV'}]},\n  {'name': '小鹏汽车',\n   'children': [{'name': '小鹏P7'},\n    {'name': '小鹏G9'},\n    {'name': '小鹏G6'},\n    {'name': '小鹏P5'},\n    {'name': '小鹏G3'}]},\n  {'name': '岚图', 'children': [{'name': '岚图追光'}, {'name': '岚图梦想家 EV'}]},\n  {'name': '广汽集团', 'children': [{'name': '绎乐'}]},\n  {'name': '开云汽车', 'children': [{'name': '开云电皮卡'}]},\n  {'name': '开沃汽车',\n   'children': [{'name': '开沃D07创业者'},\n    {'name': '开沃D10'},\n    {'name': '开沃K10'},\n    {'name': '开沃D07L'},\n    {'name': '开沃D11 EV'},\n    {'name': '开沃K15'}]},\n  {'name': '开瑞',\n   'children': [{'name': '江豚'}, {'name': '海豚EV'}, {'name': '小象EV'}]},\n  {'name': '思皓',\n   'children': [{'name': '花仙子'},\n    {'name': '思皓爱跑'},\n    {'name': '思皓E50A'},\n    {'name': '思皓E40X'}]},\n  {'name': '思铭', 'children': [{'name': '东风本田M-NV'}]},\n  {'name': '怡亚通', 'children': [{'name': 'eD1'}]},\n  {'name': '恒天', 'children': [{'name': '恒好EV7'}, {'name': '恒好EV1'}]},\n  {'name': '恒润汽车', 'children': [{'name': '小泰迪'}, {'name': '恒润H23'}]},\n  {'name': '恒驰', 'children': [{'name': '恒驰5'}]},\n  {'name': '成功汽车', 'children': [{'name': '骆驼'}, {'name': '骆驼微卡'}]},\n  {'name': '捷尼赛思',\n   'children': [{'name': '捷尼赛思GV60'},\n    {'name': '捷尼赛思纯电G80'},\n    {'name': '捷尼赛思纯电GV70'}]},\n  {'name': '捷途', 'children': [{'name': '捷途X70S EV'}]},\n  {'name': '摩登汽车', 'children': [{'name': 'Modern in'}]},\n  {'name': '敏安汽车', 'children': [{'name': '敏微ET1'}]},\n  {'name': '新吉奥汽车',\n   'children': [{'name': '吉奥奥腾'},\n    {'name': '吉奥帅凌'},\n    {'name': '吉奥帅舰'},\n    {'name': '吉奥睿征'},\n    {'name': '吉奥睿征L'},\n    {'name': '吉奥帅豹'}]},\n  {'name': '新龙马汽车',\n   'children': [{'name': '新龙马汽车启腾EX7'},\n    {'name': '新龙马汽车启腾N50 EV'},\n    {'name': '新龙马汽车启腾M70 EV'}]},\n  {'name': '日产', 'children': [{'name': 'ARIYA 艾睿雅'}]},\n  {'name': '昊铂',\n   'children': [{'name': '昊铂GT'}, {'name': '昊铂HT'}, {'name': '昊铂SSR'}]},\n  {'name': '智己汽车',\n   'children': [{'name': '智己LS6'}, {'name': '智己LS7'}, {'name': '智己L7'}]},\n  {'name': '智界', 'children': [{'name': '智界S7'}]},\n  {'name': '曹操汽车', 'children': [{'name': '曹操60'}]},\n  {'name': '朋克汽车', 'children': [{'name': '朋克多多'}, {'name': '朋克美美'}]},\n  {'name': '未奥汽车', 'children': [{'name': '未奥BOMA'}]},\n  {'name': '本田', 'children': [{'name': '本田e:NS1'}, {'name': 'e:NP1 极湃1'}]},\n  {'name': '极氪',\n   'children': [{'name': 'ZEEKR 001'},\n    {'name': 'ZEEKR X'},\n    {'name': 'ZEEKR 009'}]},\n  {'name': '极越', 'children': [{'name': '极越01'}]},\n  {'name': '橙仕',\n   'children': [{'name': '橙仕01'}, {'name': '橙仕X2'}, {'name': '橙仕X7'}]},\n  {'name': '欧拉',\n   'children': [{'name': '欧拉好猫'},\n    {'name': '欧拉闪电猫'},\n    {'name': '欧拉芭蕾猫'},\n    {'name': '欧拉好猫GT'}]},\n  {'name': '比亚迪',\n   'children': [{'name': '海鸥'},\n    {'name': '元PLUS'},\n    {'name': '海豚'},\n    {'name': '汉EV'},\n    {'name': '海豹'},\n    {'name': '秦PLUS EV'},\n    {'name': '宋PLUS EV'},\n    {'name': '唐EV'},\n    {'name': '元Pro'},\n    {'name': '秦EV'},\n    {'name': '比亚迪e2'},\n    {'name': '比亚迪e9'},\n    {'name': '比亚迪D1'},\n    {'name': '比亚迪e3'}]},\n  {'name': '比克汽车', 'children': [{'name': '比克兴熠'}]},\n  {'name': '江南汽车', 'children': [{'name': '江南U2'}]},\n  {'name': '江汽集团',\n   'children': [{'name': '江淮iEV7'}, {'name': '江淮iEVA50'}, {'name': '蓝猫'}]},\n  {'name': '江淮瑞风', 'children': [{'name': '瑞风E3'}]},\n  {'name': '江淮钇为', 'children': [{'name': '钇为3'}]},\n  {'name': '江铃',\n   'children': [{'name': 'E路顺'},\n    {'name': '特顺EV'},\n    {'name': '域虎EV'},\n    {'name': '顺达EV'},\n    {'name': '凯锐EV'}]},\n  {'name': '江铃晶马汽车', 'children': [{'name': '福运EV'}, {'name': 'E路福'}]},\n  {'name': '江铃集团新能源',\n   'children': [{'name': '易至EV3'}, {'name': '小麒麟'}, {'name': '羿'}]},\n  {'name': '沃尔沃',\n   'children': [{'name': '沃尔沃EM90'},\n    {'name': '沃尔沃C40 RECHARGE'},\n    {'name': '沃尔沃XC40 RECHARGE'}]},\n  {'name': '沙龙汽车', 'children': [{'name': '机甲龙'}]},\n  {'name': '活越', 'children': [{'name': '活越神童01'}]},\n  {'name': '海格', 'children': [{'name': '海格H6V'}]},\n  {'name': '海马', 'children': [{'name': '海马7X-E'}]},\n  {'name': '深蓝汽车', 'children': [{'name': '深蓝S7'}, {'name': '深蓝SL03'}]},\n  {'name': '特斯拉',\n   'children': [{'name': 'Model Y'},\n    {'name': 'Model 3'},\n    {'name': 'Model S'},\n    {'name': 'Model X'}]},\n  {'name': '猛士', 'children': [{'name': '猛士917'}]},\n  {'name': '玛莎拉蒂', 'children': [{'name': 'GranTurismo Folgore'}]},\n  {'name': '现代', 'children': [{'name': '名图 纯电动'}]},\n  {'name': '理念', 'children': [{'name': '广汽本田VE-1'}]},\n  {'name': '瑞驰',\n   'children': [{'name': '瑞驰EC35'},\n    {'name': '瑞驰EC31'},\n    {'name': '瑞驰EC71'},\n    {'name': '瑞驰ED71'},\n    {'name': '瑞驰EK01S'},\n    {'name': '瑞驰EK07S'},\n    {'name': '瑞驰EC72'},\n    {'name': '瑞驰EC55'},\n    {'name': '瑞驰ED75'}]},\n  {'name': '申龙客车',\n   'children': [{'name': '申龙DST神州5号'},\n    {'name': '申龙V6'},\n    {'name': '申龙地上铁510'}]},\n  {'name': '电动屋', 'children': [{'name': 'YOUNG光小新'}]},\n  {'name': '百智新能源', 'children': [{'name': '百智大熊'}]},\n  {'name': '睿蓝汽车',\n   'children': [{'name': '睿蓝7'},\n    {'name': '睿蓝9'},\n    {'name': '枫叶80v'},\n    {'name': '枫叶60s'},\n    {'name': '枫叶80v PRO'},\n    {'name': '枫叶60s PRO'}]},\n  {'name': '神州', 'children': [{'name': '航天金龙'}, {'name': 'DST神州5号'}]},\n  {'name': '福特',\n   'children': [{'name': '福特电马'}, {'name': '领界EV'}, {'name': '全顺EV'}]},\n  {'name': '福田',\n   'children': [{'name': '智蓝精灵'},\n    {'name': '图雅诺智蓝 EV'},\n    {'name': '祥菱Q'},\n    {'name': '祥菱M EV'},\n    {'name': '大将军EV皮卡'},\n    {'name': '风景智蓝G7 EV'},\n    {'name': '时代EV6'},\n    {'name': '祥菱Q EV'},\n    {'name': '祥菱V EV'},\n    {'name': '风景智蓝G5 EV'}]},\n  {'name': '红旗',\n   'children': [{'name': '红旗E-QM5'},\n    {'name': '红旗E-HS9'},\n    {'name': '红旗E-HS3'}]},\n  {'name': '腾势', 'children': [{'name': '腾势D9 EV'}, {'name': '腾势N7'}]},\n  {'name': '荣威',\n   'children': [{'name': 'CLEVER'},\n    {'name': '荣威D7 EV'},\n    {'name': '荣威iMAX8 EV'},\n    {'name': '荣威Ei5'},\n    {'name': '荣威i6 MAX EV'}]},\n  {'name': '菱势汽车', 'children': [{'name': '菱势黄金仓'}]},\n  {'name': '蓝电', 'children': [{'name': '蓝电E3'}]},\n  {'name': '蔚来',\n   'children': [{'name': '蔚来ET5'},\n    {'name': '蔚来ES6'},\n    {'name': '蔚来ES8'},\n    {'name': '蔚来ET5T'},\n    {'name': '蔚来ET7'},\n    {'name': '蔚来EC6'},\n    {'name': '蔚来ES7'},\n    {'name': '蔚来EC7'}]},\n  {'name': '起亚', 'children': [{'name': '起亚EV5'}, {'name': '起亚EV6'}]},\n  {'name': '路特斯', 'children': [{'name': '路特斯Eletre'}, {'name': 'Evija'}]},\n  {'name': '远程汽车',\n   'children': [{'name': '远程星享V'},\n    {'name': '远程星智H'},\n    {'name': '远程锋锐F3E'},\n    {'name': '远程E6'},\n    {'name': '远程星享F1E'},\n    {'name': '远程锋锐V5E'}]},\n  {'name': '金旅', 'children': [{'name': '金旅海狮EV'}, {'name': '领特EV'}]},\n  {'name': '金杯新能源', 'children': [{'name': '新海狮 EV'}, {'name': '新海豚 EV'}]},\n  {'name': '金琥新能源', 'children': [{'name': '金琥EV48'}]},\n  {'name': '金龙',\n   'children': [{'name': '龙耀8'},\n    {'name': '龙耀6'},\n    {'name': '龙耀6S'},\n    {'name': '龙耀8S'},\n    {'name': '龙耀5'}]},\n  {'name': '银隆新能源', 'children': [{'name': '银隆5024 EV'}]},\n  {'name': '长城', 'children': [{'name': '炮EV'}, {'name': '风骏EV'}]},\n  {'name': '长安',\n   'children': [{'name': '长安Lumin'}, {'name': '逸动EV'}, {'name': '览拓者EV'}]},\n  {'name': '长安凯程',\n   'children': [{'name': '睿行EM80'},\n    {'name': '睿行EM60'},\n    {'name': '长安之星9 EV'},\n    {'name': '神骐T10 EV'},\n    {'name': '长安星卡EV'},\n    {'name': '神骐T30 EV'}]},\n  {'name': '长安启源', 'children': [{'name': '长安启源A07'}]},\n  {'name': '长安欧尚', 'children': [{'name': '奔奔E-Star'}]},\n  {'name': '长安跨越',\n   'children': [{'name': '跨越星V7 EV'},\n    {'name': '跨越星V5 EV'},\n    {'name': '跨越王X1 EV'},\n    {'name': '跨越王X3 EV'},\n    {'name': '跨越者D5 EV'}]},\n  {'name': '阿维塔', 'children': [{'name': '阿维塔 11'}, {'name': '阿维塔 12'}]},\n  {'name': '雪佛兰', 'children': [{'name': '雪佛兰畅巡'}]},\n  {'name': '零跑汽车',\n   'children': [{'name': '零跑C11'}, {'name': '零跑C01'}, {'name': '零跑T03'}]},\n  {'name': '雷克萨斯', 'children': [{'name': '雷克萨斯RZ'}]},\n  {'name': '雷达汽车', 'children': [{'name': '雷达RD6'}]},\n  {'name': '领途汽车', 'children': [{'name': '缤纷'}]},\n  {'name': '飞凡汽车', 'children': [{'name': '飞凡R7'}, {'name': '飞凡F7'}]},\n  {'name': '飞碟汽车',\n   'children': [{'name': '飞碟Q2V'}, {'name': '缔途EF3'}, {'name': '飞碟Q2T'}]},\n  {'name': '马自达', 'children': [{'name': '马自达CX-30 EV'}]},\n  {'name': '高合',\n   'children': [{'name': '高合HiPhi Z'},\n    {'name': '高合HiPhi Y'},\n    {'name': '高合HiPhi X'}]},\n  {'name': '黄海', 'children': [{'name': '瑞途EV'}]}]}"
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_outter = df.drop_duplicates(subset=['outter_name'], keep='first')\n",
    "df_tree = df_outter.groupby('brand_name')['outter_name']\n",
    "data = {\n",
    "    'name': '全部',\n",
    "    'children': [\n",
    "        {\n",
    "            'name': i[0],\n",
    "            'children': [\n",
    "                {\n",
    "                    'name': j\n",
    "                } for j in i[1].values\n",
    "            ]\n",
    "        } for i in df_tree\n",
    "    ]\n",
    "}"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2023-12-04T02:12:20.631633600Z",
     "start_time": "2023-12-04T02:12:20.600205700Z"
    }
   },
   "id": "d4ddc70750c323e6"
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "outputs": [
    {
     "data": {
      "text/plain": "[{'name': 'AITO', 'value': 1},\n {'name': 'ARCFOX极狐', 'value': 3},\n {'name': 'DS', 'value': 1},\n {'name': 'LEVC', 'value': 1},\n {'name': 'Polestar极星', 'value': 3},\n {'name': 'SRM鑫源', 'value': 10},\n {'name': 'smart', 'value': 2},\n {'name': '万象汽车', 'value': 4},\n {'name': '三菱', 'value': 1},\n {'name': '上汽大通MAXUS', 'value': 10},\n {'name': '东南', 'value': 1},\n {'name': '东风', 'value': 3},\n {'name': '东风·瑞泰特', 'value': 2},\n {'name': '东风富康', 'value': 3},\n {'name': '东风小康', 'value': 2},\n {'name': '东风纳米', 'value': 2},\n {'name': '东风风光', 'value': 2},\n {'name': '东风风神', 'value': 2},\n {'name': '东风风行', 'value': 4},\n {'name': '丰田', 'value': 4},\n {'name': '九龙', 'value': 3},\n {'name': '云度', 'value': 2},\n {'name': '五十铃', 'value': 1},\n {'name': '五菱汽车', 'value': 12},\n {'name': '依维柯', 'value': 2},\n {'name': '保时捷', 'value': 1},\n {'name': '凌宝汽车', 'value': 3},\n {'name': '凯翼', 'value': 2},\n {'name': '凯迪拉克', 'value': 1},\n {'name': '凯马汽车', 'value': 1},\n {'name': '创维汽车', 'value': 1},\n {'name': '别克', 'value': 3},\n {'name': '劳斯莱斯', 'value': 1},\n {'name': '北京汽车', 'value': 5},\n {'name': '北汽制造', 'value': 5},\n {'name': '北汽昌河', 'value': 1},\n {'name': '北汽瑞翔', 'value': 1},\n {'name': '北汽雷驰', 'value': 3},\n {'name': '华凯', 'value': 2},\n {'name': '华夏领舰', 'value': 1},\n {'name': '华晨新日', 'value': 2},\n {'name': '华梓汽车', 'value': 1},\n {'name': '合创汽车', 'value': 4},\n {'name': '吉利几何', 'value': 6},\n {'name': '吉利汽车', 'value': 1},\n {'name': '名爵', 'value': 2},\n {'name': '启辰', 'value': 3},\n {'name': '哪吒汽车', 'value': 6},\n {'name': '国吉商用车', 'value': 2},\n {'name': '国新新能源', 'value': 1},\n {'name': '国金汽车', 'value': 1},\n {'name': '埃安', 'value': 4},\n {'name': '大众', 'value': 5},\n {'name': '大力牛魔王', 'value': 3},\n {'name': '大运', 'value': 2},\n {'name': '天际汽车', 'value': 1},\n {'name': '奇瑞新能源', 'value': 5},\n {'name': '奔腾', 'value': 2},\n {'name': '奔驰', 'value': 9},\n {'name': '奥迪', 'value': 7},\n {'name': '宇通客车', 'value': 1},\n {'name': '安凯客车', 'value': 2},\n {'name': '宏远汽车', 'value': 1},\n {'name': '宝马', 'value': 6},\n {'name': '宝骏', 'value': 3},\n {'name': '容大智造', 'value': 2},\n {'name': '小虎', 'value': 1},\n {'name': '小鹏汽车', 'value': 5},\n {'name': '岚图', 'value': 2},\n {'name': '广汽集团', 'value': 1},\n {'name': '开云汽车', 'value': 1},\n {'name': '开沃汽车', 'value': 6},\n {'name': '开瑞', 'value': 3},\n {'name': '思皓', 'value': 4},\n {'name': '思铭', 'value': 1},\n {'name': '怡亚通', 'value': 1},\n {'name': '恒天', 'value': 2},\n {'name': '恒润汽车', 'value': 2},\n {'name': '恒驰', 'value': 1},\n {'name': '成功汽车', 'value': 2},\n {'name': '捷尼赛思', 'value': 3},\n {'name': '捷途', 'value': 1},\n {'name': '摩登汽车', 'value': 1},\n {'name': '敏安汽车', 'value': 1},\n {'name': '新吉奥汽车', 'value': 6},\n {'name': '新龙马汽车', 'value': 3},\n {'name': '日产', 'value': 1},\n {'name': '昊铂', 'value': 3},\n {'name': '智己汽车', 'value': 3},\n {'name': '智界', 'value': 1},\n {'name': '曹操汽车', 'value': 1},\n {'name': '朋克汽车', 'value': 2},\n {'name': '未奥汽车', 'value': 1},\n {'name': '本田', 'value': 2},\n {'name': '极氪', 'value': 3},\n {'name': '极越', 'value': 1},\n {'name': '橙仕', 'value': 3},\n {'name': '欧拉', 'value': 4},\n {'name': '比亚迪', 'value': 14},\n {'name': '比克汽车', 'value': 1},\n {'name': '江南汽车', 'value': 1},\n {'name': '江汽集团', 'value': 3},\n {'name': '江淮瑞风', 'value': 1},\n {'name': '江淮钇为', 'value': 1},\n {'name': '江铃', 'value': 5},\n {'name': '江铃晶马汽车', 'value': 2},\n {'name': '江铃集团新能源', 'value': 3},\n {'name': '沃尔沃', 'value': 3},\n {'name': '沙龙汽车', 'value': 1},\n {'name': '活越', 'value': 1},\n {'name': '海格', 'value': 1},\n {'name': '海马', 'value': 1},\n {'name': '深蓝汽车', 'value': 2},\n {'name': '特斯拉', 'value': 4},\n {'name': '猛士', 'value': 1},\n {'name': '玛莎拉蒂', 'value': 1},\n {'name': '现代', 'value': 1},\n {'name': '理念', 'value': 1},\n {'name': '瑞驰', 'value': 9},\n {'name': '申龙客车', 'value': 3},\n {'name': '电动屋', 'value': 1},\n {'name': '百智新能源', 'value': 1},\n {'name': '睿蓝汽车', 'value': 6},\n {'name': '神州', 'value': 2},\n {'name': '福特', 'value': 3},\n {'name': '福田', 'value': 10},\n {'name': '红旗', 'value': 3},\n {'name': '腾势', 'value': 2},\n {'name': '荣威', 'value': 5},\n {'name': '菱势汽车', 'value': 1},\n {'name': '蓝电', 'value': 1},\n {'name': '蔚来', 'value': 8},\n {'name': '起亚', 'value': 2},\n {'name': '路特斯', 'value': 2},\n {'name': '远程汽车', 'value': 6},\n {'name': '金旅', 'value': 2},\n {'name': '金杯新能源', 'value': 2},\n {'name': '金琥新能源', 'value': 1},\n {'name': '金龙', 'value': 5},\n {'name': '银隆新能源', 'value': 1},\n {'name': '长城', 'value': 2},\n {'name': '长安', 'value': 3},\n {'name': '长安凯程', 'value': 6},\n {'name': '长安启源', 'value': 1},\n {'name': '长安欧尚', 'value': 1},\n {'name': '长安跨越', 'value': 5},\n {'name': '阿维塔', 'value': 2},\n {'name': '雪佛兰', 'value': 1},\n {'name': '零跑汽车', 'value': 3},\n {'name': '雷克萨斯', 'value': 1},\n {'name': '雷达汽车', 'value': 1},\n {'name': '领途汽车', 'value': 1},\n {'name': '飞凡汽车', 'value': 2},\n {'name': '飞碟汽车', 'value': 3},\n {'name': '马自达', 'value': 1},\n {'name': '高合', 'value': 3},\n {'name': '黄海', 'value': 1}]"
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_outter = df.drop_duplicates(subset=['outter_name'], keep='first')\n",
    "df_word = df_outter.groupby('brand_name')['outter_name'].count().reset_index()\n",
    "[\n",
    "    {\n",
    "        'name': i[0],\n",
    "        'value': i[1]\n",
    "    } for i in df_word.values\n",
    "]"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2023-12-04T02:18:48.268200800Z",
     "start_time": "2023-12-04T02:18:48.243564400Z"
    }
   },
   "id": "364b7bb6e3fb8649"
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "outputs": [
    {
     "data": {
      "text/plain": "[{'value': 1907, 'name': '>10万'},\n {'value': 715, 'name': '>20万'},\n {'value': 311, 'name': '>30万'},\n {'value': 150, 'name': '>40万'},\n {'value': 94, 'name': '>50万'}]"
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "[\n",
    "    {\n",
    "        'value':len(df[(df['official_price'] > i * 10)]),\n",
    "        'name':'>{}万'.format(i * 10)\n",
    "    } for i in range(1, 6)\n",
    "]"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2023-12-04T02:25:20.703799100Z",
     "start_time": "2023-12-04T02:25:20.692601400Z"
    }
   },
   "id": "bdb0cd469e5a1975"
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
